package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

@Mapper
public interface UserMapper {
    /*
    * 根据openid检查用户是否存在
    * */
    @Select("select * from user where openid = #{openid}")
    User getByOpenid(String openid);

    void insert(User user);

    /*
    * 根据id查询
    * */
    @Select("select * from user where id = #{id}")
    User getById(Long id);

    /*
    * 查询到给定时间为止的用户总数
    * */
    @Select("select count(id) from user where create_time <=#{time}")
    Integer countByCreateTime(LocalDateTime time);
}
